Skip to content

Conversation

@lcolitti
Copy link
Contributor

Currently, when an output is destroyed, views are transferred to the new output in roughly the same position as they were on the old output, but they are all transferred to the first workspace.

This is annoying: if they were not on the first workspace, then the user must have moved them, and after they're transferred, the user must will have to move them agein.

Instead, in the (common?) case that the old and the new output have the same number of workspaces, move each view to the same workspace it was on before.

@soreau
Copy link
Member

soreau commented Mar 29, 2024

Is this not able to be fixed by only modifying the preserve-output plugin? Seems like that might be a better place for this to live.

@lcolitti
Copy link
Contributor Author

Is this not able to be fixed by only modifying the preserve-output plugin? Seems like that might be a better place for this to live.

Perhaps, but why require the user to run the preserve output plugin to get the correct behaviour? Core obviously needs to do the right thing here in case the user is not running the plugin. And in fact the code does try to do the right thing, by putting the views in roughly the same place as they were on the previous output, scaled by the ratio of output sizes. This commit just makes it put the views on the right desktop as well. 😄

Copy link
Member

@ammen99 ammen99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't ideal because move_view_to_output is used in other places as well, for example the oswitch plugin, and this will break the plugin.

I think the idea in general makes sense when destroying an output. It might make sense to add more flags to the function (instead of a bool). Maybe even add two overloads (to avoid breaking changes), one bool, one with flags, have one call the other :)

@lcolitti lcolitti force-pushed the move-same-workspace branch 2 times, most recently from 71d21cb to 536d767 Compare April 4, 2024 12:45
@lcolitti
Copy link
Contributor Author

lcolitti commented Apr 4, 2024

I think the idea in general makes sense when destroying an output. It might make sense to add more flags to the function (instead of a bool). Maybe even add two overloads (to avoid breaking changes), one bool, one with flags, have one call the other :)

Done

@ammen99 ammen99 added the stale label Feb 17, 2025
@lcolitti lcolitti force-pushed the move-same-workspace branch 2 times, most recently from ffce329 to 9925d03 Compare November 19, 2025 23:02
@lcolitti lcolitti requested a review from ammen99 November 19, 2025 23:03
@lcolitti lcolitti force-pushed the move-same-workspace branch from 9925d03 to 68bd7f4 Compare November 19, 2025 23:19
@lcolitti
Copy link
Contributor Author

@ammen99 could you take a look? Or should I open another PR, since this one is marked stale?

{
move_view_to_output(view, to, true);
unsigned flags = VIEW_TO_OUTPUT_FLAG_RECONFIGURE | VIEW_TO_OUTPUT_FLAG_SAME_WORKSPACE;
move_view_to_output(view, to, flags);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about whether this should be an option or not, but I suppose the new behavior is pretty much an improvement over the old behavior. Putting this comment here just in case someone really wants the old behavior, let us know and we can make it an option. But if nobody complains, there is no need for the option :)

@lcolitti lcolitti force-pushed the move-same-workspace branch 2 times, most recently from ce0330b to 1d7eeb1 Compare November 25, 2025 15:25
* enough to hold the windows of the largest output that is
* being removed.
*/
wf::dimensions_t max_size = {0, 0};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey instead of this, have you tried simply using

[output:NOOP-1]
mode = 3840x2160

in the config file? I would just prefer to let the user control the size of the biggest buffer we try to allocate ourselves. We have ran into issues with too big buffers before (example

wayfire/src/render.cpp

Lines 152 to 157 in fcdc7b4

// On some systems, we may not be able to allocate very big buffers, so try to allocate a smaller
// size instead.
size = sanitize_buffer_size(size, FALLBACK_MAX_BUFFER_SIZE);
buffer.buffer = wlr_allocator_create_buffer(wf::get_core_impl().allocator, size.width,
size.height, format);
}
), so I am hesitant letting this output be potentially very big.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition, the current implementation only sets the max size the first time the noop output is created - but the second time, maybe we have an even bigger window, we calculate the max_size, but noop_output might not be null and you will hit the same issue as before.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, setting it in the config file does work. Personally I don't think this is a great solution - it will be very hard for users to understand why their windows are sometimes positioned correctly if their screen is <= 1280x720, but not if it's bigger - but at least it's possible to configure things to make it work.

I've removed this commit from the patch series for now.

Why are you concerned that the output might be too large? It's (roughly) only as large as the largest output that was already configured, so that memory was already being used, and it (roughly) only sticks around for as long as there are no other outputs - which (likely) means that nothing else is using that memory. Or is it because it could be larger, for example if you remove one output that is 128x3840 and another output that is 2160x128, the noop output becomes 3840x2160, which uses much more memory?

/**
* Change the view's output to new_output.
*/
void move_view_to_output(wayfire_toplevel_view v, wf::output_t *new_output, unsigned flags);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last nitpick, I'd prefer uint32_t as the flags type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes - if it's an API I guess it's better for it to be a fixed size.

Currently, when an output is destroyed, views are transferred to
the new output in roughly the same position as they were on the
old output, but they are all transferred to the first workspace.

This is annoying: if they were not on the first workspace, then
the user must have moved them, and after they're transferred, the
user will have to move them agein.

Instead, move each view to the same workspace it was on before,
or, if the new workspace set has a smaller grid, to the edge.
@lcolitti lcolitti force-pushed the move-same-workspace branch from 1d7eeb1 to b60a25b Compare November 25, 2025 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants